
let vm=new Vue({
    el:'#app',
    data:{
        stationNum:' ',
        machinePower:' ',
        errorNum:' ',
        currentPower:' ',
        eleToday:' ',
        eleTotal:' ',
        co2Reduce:'',
        plantingTrees:'',
        saveCoal:'',
        inverterTotal:'',
        inverterNormal:'',
        inverterBad:'',
        datas:[],
        footerDatas:[]
    },
    mounted:function(){
        this.showData();
        this.showPower();
        this.showFooter()
    },
    methods: {
        showData: function () {
            $.ajax({
                type: 'GET',
                url: "./json/plantData.json",
                // data:{type:type,ext:ext},
                dataType: "json",
                success: function (result) {
                    vm.stationNum = result.stationNum;
                    vm.machinePower = result.machinePower;
                    vm.errorNum = result.errorNum;
                    vm.currentPower = result.currentPower;
                    vm.eleToday = result.eleToday;
                    vm.eleTotal = result.eleTotal;
                    vm.co2Reduce = result.co2Reduce;
                    vm.plantingTrees = result.plantingTrees;
                    vm.saveCoal = result.saveCoal;
                    vm.inverterTotal = result.inverterTotal;
                    vm.inverterNormal = result.inverterNormal;
                    vm.inverterBad = result.inverterBad;
                    //左上角第一个圆形进度条
                    let s1=0;
                    let sobj1=setInterval(function(){
                        let perimeter=Math.PI*2*140;
                        let percent=vm.errorNum/vm.stationNum*perimeter;
                        s1++;
                        if(s1>=percent){
                            clearInterval(sobj1);
                        }
                        circle1.setAttribute("stroke-dasharray",s1+" "+(perimeter-s1))
                    },5);
                    //左上角第二个圆形进度条
                    let s2=0;
                    let sobj2=setInterval(function(){
                        let perimeter=Math.PI*2*140;
                        let percent=vm.currentPower/260*0.9*perimeter;
                        s2+=2;
                        if(s2>=percent){
                            clearInterval(sobj2);
                        }
                        circle2.setAttribute("stroke-dasharray",0.8*perimeter+" "+0.2*perimeter)
                        circle3.setAttribute("stroke-dasharray",s2+" "+(perimeter-s2))
                    },5);
                    //右侧圆形进度条
                    let s4=0;
                    let sobj4=setInterval(function(){
                        let perimeter=Math.PI*2*140;
                        let percent=vm.inverterBad/vm.inverterTotal*perimeter;
                        s4++;
                        if(s4>=percent){
                            clearInterval(sobj4);
                        }
                        circle4.setAttribute("stroke-dasharray",s4+" "+(perimeter-s4))
                    },5);
                },
            })
        },
        showPower:function () {
            jQuery.ajax({
                type: 'Get',
                url: "./json/efficacy.json",
                datatype: "json",
                success: function (data) {
                    for (let i = 0; i < data.length; i++) {
                        vm.datas.push(data[i]);
                    }
                },
            });
        },
        showFooter:function () {
            jQuery.ajax({
                type: 'Get',
                url: "./json/footer.json",
                datatype: "json",
                success: function (data) {
                    for (let n = 0; n < data.length; n++) {
                        vm.footerDatas.push(data[n]);
                    }
                },
            });
        }
    }
});